#define UNICODE // unicode must be defined for Metabase access
#define _UNICODE
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <stdlib.h>
#include <mbstring.h>


#define MAX_DATA 100
#define MYSQLSUCCESS(rc) ((rc==SQL_SUCCESS)||(rc==SQL_SUCCESS_WITH_INFO))

class odbc
{
	RETCODE rc;        // odbc return code
	HENV henv;         // Environment   
	HDBC hdbc;         // Connection handle
	HSTMT hstmt;       // Statement handle
	TCHAR szData[MAX_DATA];   // Returned data storage
	SDWORD cbData;     // Output length of data
	TCHAR chr_ds_name[SQL_MAX_DSN_LENGTH];   // Data source name

public:
	odbc();           // Constructor
	void Initialize(TCHAR * DSN_name);
	int conn(TCHAR * UserName,TCHAR * UserPassword);      // Allocate env, stat, and conn
	int exec(TCHAR *);   // Execute SQL statement
	void disconn();   // Free pointers to env, stat, conn,
                        // and disconnect
	void error_out();    // Displays errors
};

